export function allDialogForm() {
  const validatorActiveName = (rule, data, callback) => {
    if (data.length === 0) {
      callback(new Error('请选择活动名称'))
    }
    if (data.length === 7) {
      callback()
    } else {
      callback(new Error('活动数量要求为7个'))
    }
  }

  return [
    {
      label: '方案名称',
      prop: 'name',
      rules: [
        {
          required: true,
          message: '请输入方案名称',
        },
      ],
    },
    {
      type: 'select',
      label: '适用国家',
      prop: 'country_id',
      filterable: true,
      dicData: [{ id: 0, full_name: '所有国家', short_name: 'All' }, ...this.countryList],
      props: {
        label: 'full_name',
        value: 'id',
      },
      typeformat(row) {
        return `(${row?.short_name}) ${row?.full_name}`
      },
    },
    {
      type: 'select',
      label: '活动页面',
      prop: 'page_type',
      dicData: [
        { value: 0, label: 'Top UP' },
        { value: 1, label: '弹窗充值' },
      ],
      control: async (val, form) => {
        this.activeNameList = await this.queryKeyWord(val)
        return {
          activitiy_name: {
            dicData: this.activeNameList,
          },
        }
      },
    },
    {
      filterable: true,
      label: '活动名称',
      prop: 'activitiy_name',
      type: 'select',
      multiple: true,
      dicData: this.activeNameList,
      control: (val, form) => {
        return {
          first_activity_id: {
            dicData: this.activeNameList.filter(item => val?.includes(item.value)),
          },
        }
      },
      rules: [
        {
          required: true,
          validator: validatorActiveName,
          // message: '请选择活动名称',
        },
      ],
    },
    {
      type: 'select',
      label: '首选活动',
      dicData: this.activeNameList,
      prop: 'first_activity_id',
      props: {
        value: 'value',
        label: 'label',
      },
    },
    {
      type: 'radio',
      label: '活动状态',
      prop: 'status',
      dicData: [
        { value: 1, label: '开启' },
        { value: 2, label: '关闭' },
      ],
      rules: [
        {
          required: true,
          message: '请选择活动状态',
        },
      ],
    },
  ]
}
